﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using System.Web.Script.Serialization;
using System.Web.SessionState;
namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// AddDelegate 的摘要说明
    /// </summary>
    public class AddDelegate : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            BagePages bp = new BagePages();
            context.Response.ContentType = "text/plain";
            string endtimeCount = bp.GetAll("endtimeCount"); // $("#endtimeCount");
            string email = bp.GetAll("email"); //$("#email");
            string cityid = bp.GetAll("cityid"); //$("#cityid");
            string provinceid = bp.GetAll("provinceid"); //$("#provinceid");
            string phone = bp.GetAll("phone"); //$("#phone");
            string delegatepersontype = bp.GetAll("delegatepersontype"); //$("#delegatepersontype");
            string delegatename = bp.GetAll("delegatename"); //$("#delegatename");
            string delegatemoney = bp.GetAll("delegatemoney"); //$("#delegatemoney");
            string involvedcasemoney = bp.GetAll("involvedcasemoney"); //$("#involvedcasemoney");
            string delegateclaim = bp.GetAll("delegateclaim"); //$("#delegateclaim");
            string delegatecontent = bp.GetAll("delegatecontent"); //$("#delegatecontent");
            string classid = bp.GetAll("classid"); //$("#classid");
            HFModel.ResultModel result = DelegateController.getController().doAddDelegate(endtimeCount, email, cityid, provinceid, phone, delegatepersontype, delegatename, delegatemoney, involvedcasemoney, delegateclaim, delegatecontent, classid);
            context.Response.Write(this.getJSONResult(result));
            context.Response.End();
        }

        protected string getJSONResult(HFModel.ResultModel result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}